package com.ch.client.controller;


import com.ch.client.openApi.entity.Emp;
import com.ch.client.openApi.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wangzhuangzhuang
 * @DESC:
 * @date 2022-02-25 15:21
 */
@RestController
@Slf4j
public class EmpController {

	@Autowired
	private EmpService empService;

	@GetMapping("/emp/list")
	@ResponseBody
	public List<Emp> getEmpList(){
		log.info("===> getEmpList {}", empService.getEmpInfos());
		return empService.getEmpInfos();
	}

	@GetMapping("/emp/info")
	@ResponseBody
	public String getEmpInfoByName(@RequestParam(value = "name", defaultValue = "admin") String name){
		log.info("===> getEmpInfoByName the param is: {}", name);
		return empService.getEmpInfoByName(name);
	}
}